package com.cuckoo.mall.thus.menuindex.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.view.ViewGroup;

import com.cuckoo.mall.javabean.Category;
import com.cuckoo.mall.thus.menuindex.list.CategoryProductListFragment;
import com.freshchat.consumer.sdk.activity.CategoryListActivity;


import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class MyViewPageAdapter extends FragmentStatePagerAdapter {

    private List<Category> categories = new ArrayList<>();

    public MyViewPageAdapter(FragmentManager fm, List<Category> datas) {
        super(fm);
        this.categories = datas;
    }


    @Override
    public Fragment getItem(int position) {
        CategoryProductListFragment fragment = CategoryProductListFragment.newInstance(categories.get(position).getId());
        return fragment;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        return super.instantiateItem(container, position);
    }

    @Override
    public int getCount() {
        return categories.size();
    }
}
